package com.qf.web;

import com.qf.pojo.Product;
import com.qf.service.ProductService;
import com.qf.service.serviceimpl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/show")
public class IndexServlet extends BaseServlet {
    public void ShowProduct(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException   {
        /**
         * 查找最新商品和热门商品
         */
        ProductService ps = new ProductServiceImpl();
        List<Product> newProduct = ps.findNewProduct();
        List<Product> hotProduct = ps.hotProduct();
        request.setAttribute("newProduct",newProduct);
        request.setAttribute("hotProduct",hotProduct);
        request.getRequestDispatcher("/jsp/index.jsp").forward(request,response);
    }
}
